﻿using AuthCenter_HuangJingtao.Domain;
using AuthCenter_HuangJingtao.ErrorCode;
using AuthCenter_HuangJingtao.Infrastructure.Imterfaces;
using AuthCenter_HuangJingtao.Read.Api.Application.Command.AppaLL;
using MediatR;
using Microsoft.EntityFrameworkCore;

namespace AuthCenter_HuangJingtao.Read.Api.Application.CommandHandler.AppHandler
{
    public class ShowXianCommandHandler : IRequestHandler<ShowXianCommand, ApiResult<List<Xians>>>
    {
        IBaseReponsitory<Xians> xians;

        public ShowXianCommandHandler(IBaseReponsitory<Xians> xians)
        {
            this.xians = xians;
        }

        public async Task<ApiResult<List<Xians>>> Handle(ShowXianCommand request, CancellationToken cancellationToken)
        {
            var list =await xians.GetQuery().Where(c=>c.CityId==request.CityId).ToListAsync();
            return new ApiResult<List<Xians>> 
            {
                Code=ApiEnum.Success,
                Message= "获取成功",
                Data =list
            };

        }
    }
}
